package test.aspecct;

import org.apache.commons.lang.time.StopWatch;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * Created on 2016/7/8.
 */
@Aspect
public class PAspect {
    @Pointcut("execution(public void *.hi())")
    public void pointcutName() {
    }

    @Around("pointcutName()")
    public Object pTrace(ProceedingJoinPoint joinPoint) throws Throwable {
        StopWatch watch = new StopWatch();
        try {
            watch.start();
            return joinPoint.proceed();
        } finally {
            watch.stop();
            System.out.println("watch = " + watch);
        }
    }
}
